﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Warehouse.UI.WinForm.Properties;
using Warehouse.UI.WinForm.Forms;

namespace Warehouse.UI.WinForm
{
    public partial class frmMain : Form
    {
        private void _initCreate()
        {
            this.Text = Resources.ProgramName;
        }

        public frmMain()
        {
            InitializeComponent();
            _initCreate();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            //
        }

        private void frmMain_Shown(object sender, EventArgs e)
        {
            _login();
        }

        private void _enableAllMenu()
        {
            //
        }

        private void _disableAllMenu()
        {
            //
        }

        private void _closeAllForm()
        {
            foreach (Form f in this.MdiChildren)
            {
                f.Close();
            }
        }

        private void _miniAllForm()
        {
            foreach (Form f in this.MdiChildren)
            {
                f.WindowState = FormWindowState.Minimized;
            }
        }

        private void miClose_Click(object sender, EventArgs e)
        {
            _closeAllForm();
            this.Close();
        }

        private void miLogin_Click(object sender, EventArgs e)
        {
            _login();
        }

        private bool _login()
        {
            _disableAllMenu();
            _closeAllForm();
            var f = new frmLogin("admin", "admin");
            if (f.ShowDialog() == DialogResult.OK)
            {
                _enableAllMenu();
                this.WindowState = FormWindowState.Maximized;
                return true;
            }
            else
            {
                _disableAllMenu();
                return false;
            }
        }

        private void miList1Test_Click(object sender, EventArgs e)
        {
            /*var f = new frmList1User
            {
                MdiParent = this,
                //ListState = ListState.CanEdit,
            };
            f.Show();*/
            /*var f = new Form1
                        {
                            MdiParent = this,
                        };
            f.Show();*/
        }

        private void miMiniAll_Click(object sender, EventArgs e)
        {
            _miniAllForm();
        }

        private void miCloseAll_Click(object sender, EventArgs e)
        {
            _closeAllForm();
        }

        private void miListUser_Click(object sender, EventArgs e)
        {
            /*var f = new frmList1User
            {
                MdiParent = this,
                TitleText = "用户",
                //ListState = ListState.CanEdit,
            };
            f.Show();*/
        }

        private void miChangePasswd_Click(object sender, EventArgs e)
        {
            //
        }

    }
}
